<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>数据类型转换-数字型</title>
  <style>
    div {
      width: 100px;
      height: 100px;
    }
  </style>
</head>

<body>
  <script>
    // 类型转换
    // Number数据
    console.log(Number('1'));
    console.log(Number('abc'))   //NaN

    // pareInt数据
    console.log(parseInt('12.99'));
    console.log(parseInt('12.99px'));
    console.log(parseInt('abc12.99'));


    // pareFloat数据
    console.log(parseFloat('12.99'));
    console.log(parseFloat('12.99px'));
    console.log(parseFloat('abc12.99'));


    // 显式类型转换实例代码
    let num1 = +prompt('请输入你那的工资')
    let num2 = +prompt('请输入你那的工资')
    alert(`
       可能工资 ${num1 + num2}
    `)


    // 转化为布尔类型
    // true==1   false==0  null==0   undefined  NaN
    console.log(Number(true));
    console.log(Number(false));
    console.log(Number(null));
    console.log(Number(undefined));

  </script>
</body>

</html>